package cn.kuporo.seckill.order.application.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author: kuporo
 * @since: 2025/8/4
 * @description: 扣减库存结果枚举
 */
@Getter
@AllArgsConstructor
public enum DecrementsStockResult {
    STOCK_NOT_EXISTS(-1L),
    STOCK_LT_ZERO(-2L),
    SUCCESS(1L)
    ;
    
    private final Long result;

    /**
     * 根据类型 result 获取对应的枚举
     *
     */
    public static DecrementsStockResult valueOf(Long result) {
        return Arrays.stream(DecrementsStockResult.values()).filter(x -> x.getResult().equals(result)).findFirst().orElse(null);
    }
    
    
}
